added SSCLI 1.0
[windows-sources.git] / shared source / wpf / src / host / shimimpl / hostshim.hxx
blob298f6206e59b75eb944ced4ea90cd189512cfb65
1 //------------------------------------------------------------------------
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // Description:
6 // Implements the minimal set of interfaces required for
7 // the version-independent hosting shim.
8 //
9 // History:
10 // 2005/05/09 - [....]
11 // Created
12 // 2007/09/20 - [....]
13 // Ported Windows->DevDiv. See SourcesHistory.txt.
15 //------------------------------------------------------------------------
17 #pragma once
19 typedef enum ActivationType
21 Unknown = 0,
22 FileActivation = 0x01,
23 MonikerActivation = 0x02,
24 HistoryActivation = 0x04
27 class CHostShim :
28 public IOleObject,
29 public IStdMarshalInfo,
30 public IObjectWithSite,
31 public IHlinkTarget
33 public:
34 CHostShim();
35 ~CHostShim();
37 static CHostShim* GetInstance();
38 static CVersion* GetValidVersion();
40 // IUnknown methods
41 STDMETHODIMP QueryInterface( __in_ecount(1) REFIID, __deref_out_ecount(1) LPVOID*);
42 STDMETHODIMP_(DWORD) AddRef();
43 STDMETHODIMP_(DWORD) Release();
45 // IStdMarshalInfo
46 STDMETHODIMP GetClassForHandler(DWORD dwDestContext, void * pvDestContext, CLSID * pClsid);
48 // IObjectWithSite
49 // The IE in-proc handler (CBrowserInprocHandler) passes its implementation of IHostBrowser to SetSite().
50 STDMETHODIMP SetSite(IUnknown *pUnkSite);
51 STDMETHODIMP GetSite(REFIID riid, /* [iid_is][out] */ void **ppvSite);
53 // IHlinkTarget methods
54 STDMETHODIMP SetBrowseContext(__in_ecount_opt(1) IHlinkBrowseContext *pihlbc);
55 STDMETHODIMP GetBrowseContext(__deref_out_ecount(1) IHlinkBrowseContext **ppihlbc);
56 STDMETHODIMP Navigate(DWORD grfHLNF,__in_ecount_opt(INTERNET_MAX_URL_LENGTH+1) LPCWSTR pwzJumpLocation);
57 STDMETHODIMP GetMoniker(__in_ecount(1) LPCWSTR pwzLocation, DWORD dwAssign, __deref_out_ecount(1) IMoniker **ppimkLocation);
58 STDMETHODIMP GetFriendlyName( __in_ecount(1) LPCWSTR pwzLocation, __deref_out_ecount(1) LPWSTR *ppwzFriendlyName);
60 // IOleObject methods
62 // When we are being activated from IPersistHistory, the browser unfortunately requests IOleObject and
63 // calls SetClientSite before QI'ing for IPersistHistory. Therfore we need this implementation here, which
64 // delegates to a "real" object in the DLL. When SetClientSite is called, we hold onto it until we've reached
65 // a point where we have the DLL and can call SetClientSite on the "real" OleObject.
66 void SetOleObjectDelegate(IOleObject* pOleObjectDelegate);
67 IOleObject* GetOleObjectDelegate() { return m_pOleObjectDelegate; }
69 virtual STDMETHODIMP SetClientSite(__in LPOLECLIENTSITE pClientSite);
70 virtual STDMETHODIMP Advise(__in LPADVISESINK pAdvSink, __out LPDWORD pdwConnection);
71 virtual STDMETHODIMP SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szCOntainerObj);
72 virtual STDMETHODIMP DoVerb(LONG iVerb, __in_opt LPMSG lpMsg, __in LPOLECLIENTSITE pActiveSite, LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect);
73 virtual STDMETHODIMP GetExtent(DWORD dwDrawAspect, LPSIZEL psizel);
74 virtual STDMETHODIMP Update();
75 virtual STDMETHODIMP Close(DWORD dwSaveOption);
76 virtual STDMETHODIMP Unadvise(DWORD dwToken);
77 virtual STDMETHODIMP EnumVerbs(LPENUMOLEVERB* ppEnumOleVerb);
78 virtual STDMETHODIMP GetClientSite(__out LPOLECLIENTSITE* ppClientSite);
79 virtual STDMETHODIMP SetMoniker(DWORD dwWhichMoniker, LPMONIKER pmk);
80 virtual STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, __out LPMONIKER* ppmk);
81 virtual STDMETHODIMP InitFromData(LPDATAOBJECT pDataObject, BOOL fCreation, DWORD dwReserved);
82 virtual STDMETHODIMP GetClipboardData(DWORD dwReserved, __out LPDATAOBJECT* ppDataObject);
83 virtual STDMETHODIMP IsUpToDate();
84 virtual STDMETHODIMP GetUserClassID(__out CLSID* pclsId);
85 virtual STDMETHODIMP GetUserType(DWORD dwFormOfType, __out LPOLESTR* pszUserType);
86 virtual STDMETHODIMP SetExtent(DWORD dwDrawAspect, LPSIZEL psizel);
87 virtual STDMETHODIMP EnumAdvise(__out LPENUMSTATDATA* ppenumAdvise);
88 virtual STDMETHODIMP GetMiscStatus(DWORD dwAspect, __out LPDWORD pdwStatus);
89 virtual STDMETHODIMP SetColorScheme(LPLOGPALETTE pLogPal);
91 // Other public methods
92 void Execute(); // Invokes Watson and terminates on failure.
93 STDMETHODIMP GetClassID(__out_ecount(1) LPCLSID);
95 void SetMimeType(MimeType mimeType) { m_mimeType = mimeType; }
96 MimeType GetMimeType() { return m_mimeType; }
98 // When IPersistMoniker::Load is called, it will bail for local file activation, to allow
99 // IPersistFile to take it. It does not allow non-local file: activation. In some cases, e.g.
100 // being launched from a hyperlink in Word, IPersistMoniker::Load is NOT called, so we have then
101 // IsAllowPersistFileLoadSet method.
102 void SetAllowPersistFileLoad(BOOL bAllow) { m_bAllowPersistFileLoad = bAllow; m_bAllowPersistFileLoadSet = TRUE; }
103 BOOL GetAllowPersistFileLoad() { return m_bAllowPersistFileLoad; }
104 BOOL IsAllowPersistFileLoadSet() { return m_bAllowPersistFileLoadSet; }
106 void SetByteWrapperImpl(class ByteWrapperImpl* pByteWrapperImpl) { m_pByteWrapperImpl = pByteWrapperImpl; }
107 ByteWrapperImpl* GetByteWrapperImpl() { return m_pByteWrapperImpl; }
109 void SetByteRangeDownloaderHelper(IByteRangeDownloaderService* pByteRangeDownloaderService) { m_pByteRangeDownloaderService = pByteRangeDownloaderService; }
110 IByteRangeDownloaderService* GetByteRangeDownloaderHelper() { return m_pByteRangeDownloaderService; }
112 void SetHistoryStream(IStream* pHistoryStream) { m_pHistoryStream = pHistoryStream; }
113 LPSTREAM GetHistoryStream() { return m_pHistoryStream; }
115 void SetDocumentStream(LPSTREAM pDocumentStream) { m_pDocumentStream = pDocumentStream; }
116 LPSTREAM GetDocumentStream() { return m_pDocumentStream; }
118 HANDLE GetDownloadCompletedEvent() { return m_hDownloadCompletedEvent; }
120 HRESULT SaveToHistory(__in_ecount(1) IStream* pHistoryStream);
121 HRESULT LoadFromHistory(__in_ecount(1) IStream* pHistoryStream, __in_ecount(1) IBindCtx* pBindCtx);
123 CVersion* GetVersion() { return m_pVersion; }
125 void SetErrorMessageToDisplay(LPCWSTR msg) { m_strErrorMessageToDisplay.SetValue(msg); }
127 // Plain string properties
128 STRING_PROP(StartupUri);
129 STRING_PROP(StartupLocation);
130 STRING_PROP(LocalDeploymentManifestPath);
131 STRING_PROP(RequestedVersion);
132 STRING_PROP(ApplicationIdentity);
134 ActivationType GetActivationType() { return m_activationType; }
135 void SetActivationType(ActivationType activationType) { m_activationType = activationType; }
137 private:
138 HRESULT DetermineRequestedVersion();
139 void InvokeFrameworkBootstrapperWithFallback();
140 HRESULT InvokeFrameworkBootstrapper();
142 private:
143 static CHostShim* m_pInstance;
144 long m_ObjRefCount;
146 IUnknown* m_pUnkSite;
147 LPUNKNOWN m_pInnerObject;
149 CVersion* m_pVersion;
150 class CPersistMoniker* m_pPersistMoniker;
151 class CPersistFile* m_pPersistFile;
152 class CPersistHistory* m_pPersistHistory;
153 ByteWrapperImpl* m_pByteWrapperImpl;
154 IByteRangeDownloaderService* m_pByteRangeDownloaderService;
156 CString m_strStartupUri;
157 CString m_strStartupLocation;
158 CString m_strLocalDeploymentManifestPath;
159 CString m_strRequestedVersion;
160 CString m_strApplicationIdentity;
161 CString m_strErrorMessageToDisplay; // see ActivateParameters::pswzErrorMessageFromShim
163 LPSTREAM m_pHistoryStream;
164 LPSTREAM m_pDocumentStream;
165 MimeType m_mimeType;
166 BOOL m_bAllowPersistFileLoad;
167 BOOL m_bAllowPersistFileLoadSet;
169 HANDLE m_hDownloadCompletedEvent; // Event triggers when download is completed
171 ActivationType m_activationType;
172 bool m_bInvokeFrameworkBootstrapper;
174 IOleObject* m_pOleObjectDelegate;
175 LPOLECLIENTSITE m_pPendingClientSite;